package com.cuckoo.mall.thus.start;

import android.app.Application;

import com.alibaba.android.arouter.launcher.ARouter;
import com.bgn.baseframe.LibLoader;
import com.cuckoo.mall.network.Constants;
import com.cuckoo.mall.thus.manager.UserInfoManager;
//import com.mob.MobSDK;

/**
 * 作者：wl on 2017/9/14 17:35
 * 邮箱：wanglun@stosz.com
 */
public class AppLoader extends Application {
     //最终效果
    private static Application mInstance;


    public static Application getInstance() {
        return mInstance;
    }


    @Override
    public void onCreate() {
        super.onCreate();

        // DaemonEnv.initialize(this, ActiveService.class,3 * 60 * 1000);
        mInstance = this;
        //initLeakCanary();
        //initFreshChat();
        LibLoader.init(this);
        initAppSdks();
        UserInfoManager.getInstance();
    }

//    public void initLeakCanary() {
//        if (LeakCanary.isInAnalyzerProcess(getApplication())) {
//            return;
//        }
//        LeakCanary.install(getApplication());
//    }

//    public void initFreshChat() {
//        FreshchatConfig freshchatConfig = new FreshchatConfig("f71bcc2e-4777-4747-b89c-420773b20fa3", "5b2744c0-9070-475c-b527-8dc5de57744e");
//        freshchatConfig.setCameraCaptureEnabled(true);
//        freshchatConfig.setGallerySelectionEnabled(true);
//        Freshchat.getInstance(mInstance).init(freshchatConfig);
//    }

    public void initAppSdks() {

        if (isDebug()) {           // 这两行必须写在init之前，否则这些配置在init过程中将无效
            ARouter.openLog();     // 打印日志
            ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行，必须开启调试模式！线上版本需要关闭,否则有安全风险)
        }
        ARouter.init(mInstance); // 尽可能早，推荐在Application中初始化

    }

    private boolean isDebug() {
        return Constants.IS_DEBUG;
    }

}
